clear 
set more off

/*NOTE: PSID_retrospective_analysis.dta is created in the 
        build/PSID folder. */

    use  "$PSID/output/PSID_retrospective_analysis.dta", clear
    local yy "70"
    local year "1997"
    keep if year==`year' & age>=30 & age<=50
        
* Restrict sample
    drop if log_father_around1970_1yr==. | log_father_retro_70==. | ///
    log_father_1yrs_70==. | log_father_actual_1yrs==. | log_father_actual_5yrs==.

* Logs
     estimates clear 

     gen indep=.

     foreach x in log_father_around1970_1yr log_father_retro_70 log_father_1yrs_70 log_father_actual_1yrs {
        replace indep = `x'
        eststo: reg log_father_actual_5yrs indep  [aw=xsection_weight] , cluster(father_id)
     }

     label var indep "Logged income"

     #delimit ; 
        esttab using "$Mydirectory2/appendix_c/PSID_incomescores_log_1997.tex", replace booktabs nostar label  
        keep(indep) nobase noomit nonote alignment(c c) width(\hsize) se(3) b(3) brackets
        mtitle("\shortstack{Self-reported, \\ in 1970}" "Retrospective" "\shortstack{Self-reported, \\ 1 year, age 40 }" "\shortstack{Self-reported, \\ 1 year, age 40 }")
        mgroups("Predicted Income" "Actual Income", pattern(1 0 0 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) 
        stats(N r2, fmt(%09.0gc %09.2fc) label("Observations" "R-squared")) 
     ;
     #delimit cr